<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2020-01-04 17:13:00
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-05-23 10:48:28
 */ 

namespace app\common\model;
use think\Model;
use think\Db;
/**
 * ============================================================================
 * DSMall多用户商城
 * ============================================================================
 * 版权所有 2014-2028 长沙德尚网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.csdeshang.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * 数据层模型
 */
class Invoice extends Model {

    public $page_info;



    /**
     * 发票类型列表
     * @access public
     * @author csdeshang
     * @param type $condition 条件
     * @param type $page 分页
     * @param type $limit 限制
     * @param type $fields 字段
     * @return array
     */
    public function getInvoiceList($condition = array(), $page = '', $limit = '', $fields = '*') {
        $result_paginate = db('invoice_type')->field($fields)->where($condition)->order('sort asc,id desc')->paginate($page,false,['query' => request()->param()]);
        $this->page_info = $result_paginate;
        $result = $result_paginate->items();
        $result = ds_change_arraykey($result, 'id');
        return $result;
    }

    public function getInvoiceList2($condition = array(), $page = '', $limit = ''){
        $tblname='invoice';
        $fields='a.invoice_id,b.member_name,c.name,c.type,a.invoice_type,c.billing_type,ap.invoice_status,ap.invoice_operation_time,ap.invoice_operation_name';
        $condition['c.status']=1;
        $condition['c.is_del']=0;
        $condition['ap.invoice_status']=3;
        $result_paginate = db( $tblname . ' a' )
            ->join ( '__MEMBER__ b', 'a.member_id=b.member_id' )
            ->join ( '__INVOICE_TYPE__ c', 'a.invoice_type_id=c.id' )
            ->join ( 'app_order ap', 'ap.app_order_id=a.app_order_id' )
            ->field($fields)
            ->where($condition)
            ->paginate($page,false,['query' => request()->param()]);
        $this->page_info = $result_paginate;
        $result = $result_paginate->items();
        $result = ds_change_arraykey($result, 'invoice_id');
        return $result;

    }

public function getInvoiceList3($condition = array(), $page = '', $limit = ''){
        $tblname='invoice';
        $fields='a.invoice_id,b.member_name,c.name,c.type,c.billing_type,ap.invoice_status,ap.invoice_operation_time,ap.invoice_operation_name';
        // var_dump($condition);die;
        $condition['c.status']=1;
        $condition['c.is_del']=0;
        $condition['ap.invoice_status']=2;
        $result_paginate = db( $tblname . ' a' )
            ->join ( '__MEMBER__ b', 'a.member_id=b.member_id' )
            ->join ( '__INVOICE_TYPE__ c', 'a.invoice_type_id=c.id' )
            ->join ( 'app_order ap', 'ap.app_order_id=a.app_order_id' )
            ->field($fields)
            ->where($condition)
            ->paginate($page,false,['query' => request()->param()]);
        $this->page_info = $result_paginate;
        $result = $result_paginate->items();
        $result = ds_change_arraykey($result, 'invoice_id');
        return $result;
    }


}

?>
